<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改公式编辑')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-formula-edit" th:object="${formula}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-2 control-label">公式名：</label>
                <div class="col-sm-10">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">内容：</label>
                <div class="col-sm-10">
                    <input id="content" name="content" type="hidden" th:field="*{content}" >
                    <div id="contentEditor" class="summernote"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">排序：</label>
                <div class="col-sm-10">
                    <input name="vsort" th:field="*{vsort}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-larger-js" />
    <script type="text/javascript">
        var prefix = ctx + "formula/formula";
        $("#form-formula-edit").validate({
            focusCleanup: true
        });


        $(function() {
			$('.summernote').summernote({
				placeholder : '请输入内容',
				height : 400,
				lang : 'zh-CN',
				followingToolbar : false
			});

			var content = $("#content").val();
			$('#contentEditor').summernote('code', content);
		});


        function submitHandler() {
            if ($.validate.form()) {
                var content = $('#contentEditor').summernote('code');
				$("#content").val(content);
                $.operate.save(prefix + "/edit", $('#form-formula-edit').serialize());
            }
        }
    </script>
</body>
</html>